const old_arr = [1,[2,3,[4,5,[6,7]]]]
const new_arr = old_arr.flat(4)
console.log(new_arr) //[1,2,3,4,5,6,7]